#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project ：turbo 
@File    ：serializers.py
@Author  ：赵加响
@Date    ：2023/5/26 11:25 
@Desc    ：
"""
from rest_framework import serializers

from apps.codetable.models import CodeTableDetail


class CodeTableSerializer(serializers.ModelSerializer):
    value = serializers.SerializerMethodField()
    label = serializers.SerializerMethodField()

    class Meta:
        model = CodeTableDetail
        fields = ('id', 'value', 'label')

    def get_value(self, obj):
        return obj.code

    def get_label(self, obj):
        return obj.name
